package com.ruanda.mapper;

import com.ruanda.domain.Sku;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
* @author 亦樂
* @description 针对表【sku(单品SKU表)】的数据库操作Mapper
* @createDate 2024-09-05 16:57:58
* @Entity com.ruanda.domain.Sku
*/
public interface SkuMapper extends BaseMapper<Sku> {
    
    @Update("update sku set stocks = stocks + #{count},actual_stocks = actual_stocks +#{count},version = version + 1 where sku_id = #{skuId} and version = #{version} and (actual_stocks + #{count}) >= 0")
    Integer updateSkuStock(@Param("skuId") Long skuId, @Param("count") Integer count, @Param("version") Integer version);
}




